/* $Id: guiMsg.h V1.0 2001/10/19 */
/*************************************************************************
 *    This source code has been made available to you by EPSON on an AS-IS
 *    basis.  Anyone receiving this source is licensed under EPSON
 *    copyrights to use it in any way he or she deems fit, including
 *    copying it, modifying it, compiling it, and redistributing it either
 *    with or without modifications.
 *
 *    Any person who transfers this source code or any derivative work
 *    must include the EPSON copyright notice, this paragraph, and the
 *    preceding two paragraphs in the transferred software.
 *
 *    COPYRIGHT   EPSON  CORPORATION 2001
 *    LICENSED MATERIAL  -  PROGRAM PROPERTY OF EPSON
 ***********************************************************************/

/***********************************************************************
  * FILE: guiMsg.h
  * MODULE: OUTPUT
  *
  * PURPOSE:
  * AUTHOR(S): ChenHong
  * GROUP: GUI Group
  * DATE CREATED: 2001/10/19
  * REFERENCE DOCUMENT ID:
  * MODIFICATIONS:
  *    Date        userName     Description
  *   2001/10/19   ChenHong       Create this file
  **********************************************************************/

#ifndef _GUIMSG_H
#define _GUIMSG_H

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus */

typedef struct T_MSG_QMsg
{
    T_GUI_Msg                 Msg;
    struct T_MSG_QMsg *       next;
}T_MSG_QMsg;
typedef T_MSG_QMsg* T_MSG_pQMsg;

typedef struct T_MSG_MsgQueue T_MSG_MsgQueue;
typedef T_MSG_MsgQueue* T_MSG_pMsgQueue;

typedef void (* T_MSG_IdleHandler) (T_MSG_pMsgQueue msg_que,T_BOOL IsReturn);

#define DEF_MSGQUEUE_LEN    16
#define DEF_NR_TIMERS       16

/* the MSGQUEUE struct is a internal struct. */
struct T_MSG_MsgQueue
{
    T_UWORD dwState;              /* message queue states */

    T_MSG_pQMsg  pFirstNotifyMsg;     /* head of the notify message queue */
    T_MSG_pQMsg  pLastNotifyMsg;      /* tail of the notify message queue */

    T_MSG_IdleHandler OnIdle;         /* Idle handler */


    T_GUI_Msg * msg;                   /* post message buffer */
    T_WORD len;                   /* buffer len */
    T_WORD ReadPos, WritePos;     /* positions for reading and writing */

    /* One GUI application can support at most 16 timers.*/
    T_GUI_HWND TimerOwner[DEF_NR_TIMERS];  /* Timer owner */
    T_WORD  TimerID[DEF_NR_TIMERS];     /* timer identifiers.*/
    T_UHWORD TimerMask;             /* used timer slots mask */

};

/* Free QMSG list */

#define SIZE_QMSG_HEAP   64

T_BOOL fnMSG_InitFreeQMSGList (T_VOID);
T_VOID fnMSG_DestroyFreeQMSGList (T_VOID);
T_BOOL fnMSG_InitMsgQueue (T_MSG_pMsgQueue pMsgQueue, T_WORD iBufferLen);
T_VOID fnMSG_DestroyMsgQueue (T_MSG_pMsgQueue pMsgQueue);

T_VOID fnMSG_IdleHandler(T_MSG_pMsgQueue msg_que,T_BOOL IsReturn);

struct T_WND_MainWin;
typedef struct T_WND_MainWin *T_WND_pMainWin;
T_WND_pMainWin fnMSG_GetMainWindow (T_GUI_HWND hWnd); /* return main window contains hWnd. */
T_WND_pMainWin fnMSG_MainWindow (T_GUI_HWND hWnd);
	/* check whether hWnd is main window and return pointer to main window hWnd. */
T_MSG_pMsgQueue fnMSG_GetMsgQueue (T_GUI_HWND hWnd);
T_EXTERN T_BOOL fnGUI_PollTime();

#ifdef __cplusplus
}
#endif  /* __cplusplus */

#endif /* _GUIMSG_H */

